//
//  MSMationCell.m
//  觅尚
//
//  Created by No.8 on 2019/4/2.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSMationCell.h"

@implementation MSMationCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    MSMationCell * cell = [tableView dequeueReusableCellWithIdentifier:[MSMationCell ID]];
    cell = [[MSMationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[MSMationCell ID]];
    cell.backgroundColor = backgroundcolor;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}

- (void)setMember{
    /** 头像*/
    self.TitleIMG = [[UIImageView alloc] initWithFrame:CGRectMake(40 * px, 30 * px, 60 * px, 60 * px)];
//    self.TitleIMG.image = [UIImage imageNamed:@"sz_icon"];
    self.TitleIMG.layer.cornerRadius = 30 * px;
    [self addSubview:self.TitleIMG];
    
    
    /** 名称*/
    self.TitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.TitleIMG.frame) + 20 * px, self.TitleIMG.y, 450 * px, self.TitleIMG.height)];
    self.TitleLabel.textColor = [UIColor grayColor];
//    self.TitleLabel.text = @"霄云一号KTV";
    self.TitleLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.TitleLabel];
    
    
    /** 名称*/
    self.ContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.TitleIMG.x, CGRectGetMaxY(self.TitleLabel.frame) + 20 * px, ScreenWidth  / 3 * 2, self.TitleIMG.height * 2)];
    self.ContentLabel.textColor = [UIColor whiteColor];
    self.ContentLabel.numberOfLines = 0;
//    self.ContentLabel.text = @"马云扫码活动获得价值12388元马云扫码活动获得价值12388元";
    self.ContentLabel.font = [UIFont systemFontOfSize:SYRealValue(28 / 2)];
    [self addSubview:self.ContentLabel];
    
    
    self.ContentIMG = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenWidth - 220 * px, self.ContentLabel.y, 180 * px, 180 * px)];
//    self.ContentIMG.image = [UIImage imageNamed:@"财务-房间结算"];
//    self.TitleIMG.image = [UIImage imageNamed:@"sz_icon"];
    [self addSubview:self.ContentIMG];
    
    self.CreatTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.TitleIMG.x, CGRectGetMaxY(self.ContentIMG.frame) - 50 * px, 400 * px, self.TitleIMG.height)];
    self.CreatTimeLabel.textColor = [UIColor grayColor];
//    self.ContentLabel.numberOfLines = 0;
    self.CreatTimeLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
//    self.CreatTimeLabel.text = @"1小时前";
    [self addSubview:self.CreatTimeLabel];
    
    
}
- (void)setModel:(MSMationModel *)model{
    _model = model;
    
    [self.TitleIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.titleUrl]] placeholderImage:[UIImage imageNamed:@"我的头像占位符"]];
    
    self.TitleLabel.text = [NSString stringWithFormat:@"%@",model.title];
    
    
    self.ContentLabel.text = [NSString stringWithFormat:@"%@",model.activeName];
    
     [self.ContentIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.activityImgRoute]] placeholderImage:[UIImage imageNamed:@"我的头像占位符"]];
    
    
    double time = [model.createTime doubleValue] / 1000.0;
    
    NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:time];
    
    NSDateFormatter *formatter = [NSDateFormatter new];
    
    [formatter setDateFormat:@"MM月dd日"];
    
    
    
    //将时间转换为字符串
    
    NSString *timeS = [formatter stringFromDate:myDate];
    self.CreatTimeLabel.text = [NSString stringWithFormat:@"%@",timeS];
}

+(NSString *)ID{
    return @"cell";
}

@end
